Add support for .NET Standard 1.x and Portable Class Library#6
Open
LonghronShen wants to merge 2 commits intojstedfast:masterfrom
Open
Add support for .NET Standard 1.x and Portable Class Library#6LonghronShen wants to merge 2 commits intojstedfast:masterfrom
LonghronShen wants to merge 2 commits intojstedfast:masterfrom
Conversation
|
Sorry for the few year bump, but i was wondering if this could be merged an uploaded to Nuget, as my project uses dotnet 5.0 and i get a build warning because the project technechally isnt "net5.0 compatible" when it works just fine |
Owner
|
@Beyley why do you need this for net50? Why not use https://www.nuget.org/packages/System.Text.Encoding.CodePages ? |
well I didn't know that existed lol thanks for letting me know |
Owner
|
Add a reference to that nuget and then, in your "Main()" method (or wherever you do initialization for your app), do: System.Text.Encoding.RegisterProvider (System.Text.CodePagesEncodingProvider.Instance);Or, if your project is a multi-targeted library, what I do is this: #if NETSTANDARD || NET5_0_OR_GREATER
var encodingProviderType = typeof (Encoding).Assembly.GetType ("System.Text.EncodingProvider");
var registerProvider = typeof (Encoding).GetMethod ("RegisterProvider", new Type[] { encodingProviderType });
if (registerProvider != null) {
try {
var assembly = Assembly.Load ("System.Text.Encoding.CodePages");
if (assembly != null) {
var providerType = assembly.GetType ("System.Text.CodePagesEncodingProvider");
var property = providerType.GetProperty ("Instance").GetGetMethod ();
var instance = property.Invoke (providerType, new object[0]);
registerProvider.Invoke (typeof (Encoding), new object[] { instance });
}
} catch (FileNotFoundException) {
}
}
#endif |
Owner
|
Oops, didn't mean to close this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for .NET Standard 1.x and Portable Class Library
Note Since .NET Standard 2.0 has added support for ANSI based encodings for asian languages, so this package is not required for that platform.